//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.dj.DjPartyLecturerInfo;
//import com.plian.system.entity.yth.dj.PartyManagement;
//import com.plian.system.mapper.yth.dj.PartyManagementMapper;
//import com.plian.system.service.yth.IPartyManagementService;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.time.ZoneId;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Optional;
//
///**
// * @Description:
// * @Author: jatpen
// * @Date: 2023/4/20 9:14 AM
// */
//@Slf4j
//@Service
//@DS("slave_1")
//public class PartyManagementServiceImpl extends ServiceImpl<PartyManagementMapper, PartyManagement> implements IPartyManagementService {
//
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<DjPartyLecturerInfo> getSyncData(Date startTime, Date endTime) {
//        List<DjPartyLecturerInfo> djPartyLecturerInfos = new ArrayList<>();
//        List<PartyManagement> partyManagements = list(new LambdaQueryWrapper<PartyManagement>()
//                .gt(Optional.ofNullable(startTime).isPresent(), PartyManagement::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), PartyManagement::getCreateTime, endTime)
//        );
//        if (CollectionUtil.isNotEmpty(partyManagements)) {
//            djPartyLecturerInfos = conversion(partyManagements);
//        }
//        return djPartyLecturerInfos;
//    }
//
//    /**
//     * 转换对象
//     *
//     * @param partyManagements
//     * @return
//     */
//    private List<DjPartyLecturerInfo> conversion(List<PartyManagement> partyManagements) {
//        List<DjPartyLecturerInfo> djPartyBrandInfoList = new ArrayList<>();
//        for (PartyManagement partyManagement : partyManagements) {
//            DjPartyLecturerInfo partyLecturerInfo = new DjPartyLecturerInfo();
//            partyLecturerInfo.setSpeakerName(partyManagement.getSpeakerName());
//            partyLecturerInfo.setSpeakerEducationBk(transSpeakerEducationDict(partyManagement.getSpeakerEducation()));
//            partyLecturerInfo.setSpeakerRank(transSpeakerProfessionalDict(partyManagement.getSpeakerProfessional()));
//            partyLecturerInfo.setSpeakerUnitId(partyManagement.getSpeakerUnit());
//            partyLecturerInfo.setSpeakerUnitName(partyManagement.getSpeakerUnit());
//            partyLecturerInfo.setSpeakerPartyStanding(partyManagement.getPartySeniority().toString());
//            partyLecturerInfo.setSpeakerTag(partyManagement.getSpeakerLabel());
//            partyLecturerInfo.setFillingUnitId(partyManagement.getReportOrgId().toString());
//            partyLecturerInfo.setFillingUnitName(partyManagement.getReportOrgName());
//            partyLecturerInfo.setFillingCreateUserCode(partyManagement.getReportUserId().toString());
//            partyLecturerInfo.setFillingCreateUserName(partyManagement.getReportUserName());
//            partyLecturerInfo.setFillingTime(Date.from(partyManagement.getReportTime().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
//            partyLecturerInfo.setDataSource(YTH_DATASOURCE_TYPE);
//            partyLecturerInfo.setDataSourceId(partyManagement.getId().toString());
//            djPartyBrandInfoList.add(partyLecturerInfo);
//        }
//        return djPartyBrandInfoList;
//    }
//
//    /**
//     * 转换职称
//     *
//     * @param
//     * @return
//     */
//    private String transSpeakerProfessionalDict(int speakerProfessional) {
//        switch (speakerProfessional) {
//            case 1:
//                return "高级";
//            case 2:
//                return "中级";
//            case 3:
//                return "初级";
//            default:
//                break;
//        }
//        return null;
//    }
//
//    /**
//     * 转换宣讲员学历
//     *
//     * @param speakerEducation
//     * @return
//     */
//    private String transSpeakerEducationDict(int speakerEducation) {
//        switch (speakerEducation) {
//            case 0:
//                return "博士研究生";
//            case 1:
//                return "硕士研究生";
//            case 2:
//                return "在职博士生";
//            case 3:
//                return "在职研究生";
//            case 4:
//                return "本科";
//            case 5:
//                return "大专";
//            case 6:
//                return "中专";
//            case 7:
//                return "高中及以下";
//            case 8:
//                return "省委党校研究生";
//            case 9:
//                return "在职本科";
//            case 10:
//                return "在职大专";
//            case 11:
//                return "中央党校大学";
//            case 12:
//                return "省委党校大学";
//            default:
//                break;
//        }
//        return null;
//    }
//
//
//}
